package ch.cyberduck.core.sds.io.swagger.client;

import ch.cyberduck.core.jersey.CustomJacksonObjectMapper;

import javax.ws.rs.ext.ContextResolver;
import java.text.DateFormat;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2020-10-15T15:35:23.522373+02:00[Europe/Zurich]")
public class JSON implements ContextResolver<ObjectMapper> {
    private ObjectMapper mapper;

    public JSON() {
        mapper = new CustomJacksonObjectMapper();
        mapper.setDateFormat(new RFC3339DateFormat());
        mapper.registerModule(new JavaTimeModule());
        mapper.registerModule(new JodaModule());
    }

    /**
     * Set the date format for JSON (de)serialization with Date properties.
     *
     * @param dateFormat Date format
     */
    public void setDateFormat(DateFormat dateFormat) {
        mapper.setDateFormat(dateFormat);
    }

    @Override
    public ObjectMapper getContext(Class<?> type) {
        return mapper;
    }
}
